package com.nhjf.admin.controller.coursesPlayback;

import net.sf.json.JSONObject;
import com.nhjf.admin.common.util.SysProperties;
import com.nhjf.admin.controller.BaseController;
import com.nhjf.admin.util.Jurisdiction;
import com.nhjf.admin.util.PictureUtil;
import com.nhjf.admin.util.ProductPicUtil;
import com.nhjf.command.system.CreateResourceCommand;
import com.nhjf.command.system.CreateRoleCommand;
import com.nhjf.common.page.Pagination;
import com.nhjf.model.coursesPlayback.CoursesPlayback;
import com.nhjf.model.system.Role;
import com.nhjf.model.system.User;
import com.nhjf.model.teachers.Courses;
import com.nhjf.model.teachers.CoursesType;
import com.nhjf.model.teachers.OperationLog;
import com.nhjf.model.teachers.OrganizationHasStudent;
import com.nhjf.model.teachers.Teacher;
import com.nhjf.pojo.dto.result.ServiceResultDto;
import com.nhjf.pojo.qo.coursesPlayback.CoursesPlaybackQo;
import com.nhjf.pojo.qo.teachers.CoursesQo;
import com.nhjf.pojo.qo.teachers.CoursesTypeQo;
import com.nhjf.pojo.qo.teachers.OrganizationHasStudentQo;
import com.nhjf.pojo.qo.teachers.TeachersQo;
import com.nhjf.service.coursesPlayback.CoursesPlaybackService;
import com.nhjf.service.teachers.CoursesService;
import com.nhjf.service.teachers.CoursesTypeService;
import com.nhjf.service.teachers.OperationLogService;
import com.nhjf.service.teachers.OrganizationHasStudentService;
import com.nhjf.service.teachers.TeachersService;

import it.sauronsoftware.jave.Encoder;
import it.sauronsoftware.jave.MultimediaInfo;

import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.util.WebUtils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;

@Controller
@RequestMapping(value = "/coursesPlayback")
public class CoursesPlaybackController extends BaseController {
	@Autowired
	private CoursesPlaybackService coursesPlaybackService;
	@Autowired
	private TeachersService teachersService;
	@Autowired
	private OrganizationHasStudentService organizationHasStudentService;

	@Autowired
	private CoursesTypeService coursesTypeService;
	@Autowired
	private OperationLogService operationLogService;


	private static String offFileName="offFlie";

	@ResponseBody
	@RequestMapping("/coursesType_Subctype")
	public String showSubctype(HttpServletRequest request, HttpServletResponse response, Model model,String typeOne) {
		Map<String, Object> resMap=new HashMap<String, Object>();
		try {
			CoursesTypeQo coursesTypeQo=new CoursesTypeQo();
			coursesTypeQo.setpId(Long.parseLong(typeOne));
			coursesTypeQo.setType(2);
			List<CoursesType> list=coursesTypeService.queryList(coursesTypeQo);
			if(list!=null) {
				resMap.put("code", "200");
				resMap.put("message", list);
				return JSONObject.fromObject(resMap).toString();
			}else {
				return "404";
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return "500";
		}
	}
	//课程列表
	@RequestMapping(value = "/coursesPlaybackpage")
	public String coursescpage(HttpServletRequest request, @ModelAttribute CoursesPlaybackQo playbackQo, Model model, @RequestParam(value = "page", defaultValue = "1") Integer page) {
		if (playbackQo == null) {
			playbackQo = new CoursesPlaybackQo();
		}
		User user=(User)Jurisdiction.getSession().getAttribute(com.nhjf.common.Constants.USER_INFO);
		Set<Role> set= user.getRoleList();
		Iterator<Role> iter = set.iterator();
		Role roles=new Role();
		while(iter.hasNext()) {
			roles=iter.next();
			break;
		}
		if("1".equals(roles.getNumber())) {

			Pagination pagination = new Pagination();
			pagination.setPageSize(6);
			pagination.setCondition(playbackQo);
			pagination.setPageNo(page);
			pagination = coursesPlaybackService.queryPagination(pagination);

			SysProperties sysProperties=SysProperties.getInstance();
			String webPath=sysProperties.get("webPath");
			model.addAttribute("CoursesQo", playbackQo);
			model.addAttribute("webPath",webPath);
			model.addAttribute("pagination", pagination);
			model.addAttribute("type", 1);
			return "/coursesPlayback/coursesPlayback_Home.html";
		} else if("3".equals(roles.getNumber())) {
			Pagination pagination = new Pagination();
			pagination.setPageSize(6);
			TeachersQo teachersQo=new  TeachersQo();
			teachersQo.setUserId(user.getId());
			Teacher teacher= teachersService.queryUnique(teachersQo);
			playbackQo.setTeacherId(teacher.getId());
			pagination.setCondition(playbackQo);
			pagination.setPageNo(page);
			pagination = coursesPlaybackService.queryPagination(pagination);
			SysProperties sysProperties=SysProperties.getInstance();
			String webPath=sysProperties.get("webPath");
			model.addAttribute("webPath",webPath);
			model.addAttribute("pagination", pagination);
			model.addAttribute("CoursesQo", playbackQo);
			model.addAttribute("type", 1);
			return "/coursesPlayback/coursesPlayback_Home.html";
		}else if("2".equals(roles.getNumber())) {
			Pagination pagination = new Pagination();
			pagination.setPageSize(6);
			TeachersQo teachersQo=new  TeachersQo();
			teachersQo.setUserId(user.getId());

			Teacher teacher= teachersService.queryUnique(teachersQo);
			playbackQo.setOrganizationId(teacher.getTraininginstitution().getId());

			pagination.setCondition(playbackQo);
			pagination.setPageNo(page);
			pagination = coursesPlaybackService.queryPagination(pagination);

			SysProperties sysProperties=SysProperties.getInstance();
			String webPath=sysProperties.get("webPath");
			model.addAttribute("CoursesQo", playbackQo);
			model.addAttribute("webPath",webPath);
			model.addAttribute("pagination", pagination);
			model.addAttribute("type", 1);

			return "/coursesPlayback/coursesPlayback_Home.html";
		}
		return "500";

	}



	//视频上传
	@ResponseBody
	@RequestMapping(value = "/uploadFile")
	public String uploadFile(@RequestParam("file") MultipartFile file,HttpServletRequest request,HttpServletResponse response) {
		Map<String, String> resMap=new HashMap<String, String>();
		String fileVideoName="";
		try {

			User user=(User)Jurisdiction.getSession().getAttribute(com.nhjf.common.Constants.USER_INFO);
			if ( user== null) {
				// 跳转到登录页面
				response.sendRedirect(request.getContextPath()+"/login");
				resMap.put("code", "500");
				resMap.put("message", "请重新登陆");
				return net.sf.json.JSONObject.fromObject(resMap).toString();
			}
			//判断文件是否为空
			if (file.isEmpty()) {
				resMap.put("code", "500");
				resMap.put("message", "上传文件不可为空");
				return net.sf.json.JSONObject.fromObject(resMap).toString();
			}


			
			//加个时间戳，尽量避免文件名称重复
			SysProperties sysProperties=SysProperties.getInstance();
			String filePath=sysProperties.get("coursesPlaybackPath");
			String fileName = offFileName;
			fileName = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())+ fileName;
			fileVideoName=fileName+file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
			String extension = FilenameUtils.getExtension(fileVideoName);
			String[] regular = { "MP4"};
			boolean flag = false;
			// 判断视频格式是否合规
			for (String str : regular) {
				if (extension.equalsIgnoreCase(str)) {
					flag = true;
				}
			}
			if (!flag) {
				try {
					throw new Exception("不是视频格式！上传失败！");
					
				} catch (Exception e) {
					e.printStackTrace();
					resMap.put("code", "500");
					resMap.put("message", "不是视频格式！上传失败！");
					return net.sf.json.JSONObject.fromObject(resMap).toString();
				}
			}
			String path = filePath +user.getId()+"/"+fileName+file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
			//String path = "E:/fileUpload/" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + "_" + fileName;
			//创建文件路径.
			File dest = new File(path);
			ProductPicUtil productPicUtil = new ProductPicUtil();
			//判断文件是否已经存在
			if (dest.exists()) {
				dest.delete();
			}
			//判断文件父目录是否存在
			if (!dest.getParentFile().exists()) {
				dest.getParentFile().mkdir();
			}
			//上传文件
			file.transferTo(dest);
			//保存文件
			//            ServiceResultDto bc=CoursesService.findadd(new CoursesQo());
		} catch (IOException e) {
			e.printStackTrace();
			resMap.put("code", "500");
			resMap.put("message", "系统繁忙");
			return net.sf.json.JSONObject.fromObject(resMap).toString();
		}
		resMap.put("code", "200");
		resMap.put("message", fileVideoName);
		return net.sf.json.JSONObject.fromObject(resMap).toString();
	}



	//去往课程页面
	@RequestMapping(value = "/add_to")
	public String addto(Model model){
		CoursesTypeQo coursesTypeQo=new CoursesTypeQo();
		coursesTypeQo.setType(1);
		List<CoursesType> coursesType =coursesTypeService.queryList(coursesTypeQo);
		model.addAttribute("coursesType",coursesType);
		return "/coursesPlayback/coursesPlayback_add.html";
	}

	//去往修改课程页面
	@RequestMapping(value = "/modify_to")
	public String modify(String id,Model model){
		CoursesTypeQo coursesTypeQo=new CoursesTypeQo();
		coursesTypeQo.setType(1);
		List<CoursesType> coursesType =coursesTypeService.queryList(coursesTypeQo);
		model.addAttribute("coursesType",coursesType);
		CoursesPlayback coursesPlayback=coursesPlaybackService.get(Long.parseLong(id));
		if(null!=coursesPlayback ) {
			SysProperties sysProperties=SysProperties.getInstance();
			String webPath=sysProperties.get("webPath");
			model.addAttribute("courses",coursesPlayback);
			model.addAttribute("webPath",webPath);
		}
		return "/coursesPlayback/coursesPlayback_modify.html";
	}

	//id课程查看
	@RequestMapping("/View_to")
	public String view(HttpServletRequest request,HttpServletResponse response,String id ,Model model) {
		try {
			User user=(User)Jurisdiction.getSession().getAttribute(com.nhjf.common.Constants.USER_INFO);
			CoursesPlayback courses= coursesPlaybackService.get(Long.parseLong(id));
			if ( user== null) {
				// 跳转到登录页面
				response.sendRedirect(request.getContextPath()+"/login");
			}else{
				if(null!=courses ) {
					SysProperties sysProperties=SysProperties.getInstance();
					String webPath=sysProperties.get("webPath");
					model.addAttribute("courses",courses);
					model.addAttribute("webPath",webPath);
					return "/coursesPlayback/coursesPlayback_View.html";
				}
			}
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return "/student/student_view.html";
	}


	//课程添加
	@ResponseBody
	@RequestMapping(value= "/coursesPlayback_add")
	public String save(String fileName,MultipartFile pic,HttpServletRequest request,HttpServletResponse response,CoursesPlaybackQo qo) {
		Map<String, Object> resMap=new HashMap<String, Object>();
		try {
			User user=(User)Jurisdiction.getSession().getAttribute(com.nhjf.common.Constants.USER_INFO);
			Set<Role> set= user.getRoleList();
			Iterator<Role> iter = set.iterator();
			Role roles=new Role();
			while(iter.hasNext()) {
				roles=iter.next();
				break;
			}
			if ( user== null) {
				// 跳转到登录页面
				response.sendRedirect(request.getContextPath()+"/login");
			}
			if("1".equals(roles.getNumber())) {
				return "505";
			} else if("3".equals(roles.getNumber()) || "2".equals(roles.getNumber())) {
				if (pic.isEmpty()) {
					resMap.put("code", "500");
					resMap.put("message", "上传图片不可为空");
					return JSONObject.fromObject(resMap).toString();
				}
				int returnTag = -1;
				SysProperties sysProperties=SysProperties.getInstance();
				String fileTemPath=sysProperties.get("coursesPlaybackPath");
				String filePath=sysProperties.get("fileUploadPath");
				String imgPath=sysProperties.get("imagePlaybackPath");
				//获取图片原始文件名
				String originalFilename = pic.getOriginalFilename();
				System.out.println(originalFilename);
				//文件名使用当前时间
				String name = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date());
				// 获取上传图片的扩展名(jpg/png/...)
				String extension = FilenameUtils.getExtension(originalFilename);
				String[] regular = { "JPG", "GIF","PNG","JPEG" ,"BMP"};
				boolean flag = false;
				// 判断文件格式是否合法
				for (String str : regular) {
					if (extension.equalsIgnoreCase(str)) {
						flag = true;
					}
				}
				if (!flag) {
					returnTag = 0;
					resMap.put("code", "500");
					resMap.put("message", "上传图片格式不正确！");
					return JSONObject.fromObject(resMap).toString();
				}
				// 图片上传的相对路径（因为相对路径放到页面上就可以显示图片）
				String path =imgPath + name + "." + extension;
				//图片上传的绝对路径

				File dir = new File(path);
				if (!dir.exists()) {
					dir.mkdirs();
				}
				// 上传图片
				pic.transferTo(new File(path));

				PictureUtil.copyFile(fileTemPath+user.getId()+"/"+fileName, filePath+user.getId()+"/"+fileName);
				File source = new File(filePath+user.getId()+"/"+fileName);
				Encoder encoder = new Encoder();
				String length = "";
				MultimediaInfo m = encoder.getInfo(source);
				System.out.println("-------"+m.getDuration());
				long ls = m.getDuration()/1000;
				int hour = (int) (ls/3600);
				int minute = (int) (ls/60);
				int second = (int) (ls-hour*3600-minute*60);
				length = minute+":"+second;
				System.out.println(length);
				//保存课程信息
				TeachersQo teachersQo=new TeachersQo();
				teachersQo.setUserId(user.getId());
				Teacher teacher=teachersService.queryUnique(teachersQo);
				if(teacher==null) {
					return "500";
				}
				qo.setUploader(teacher.getId());
				qo.setVideo(user.getId()+"/"+fileName);
				qo.setImge(name + "." + extension);
				SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");		
				java.util.Date  date=new java.util.Date();
				qo.setReleasetime(date);
				qo.setViewTime(length);
				ServiceResultDto serviceResultDto=coursesPlaybackService.findadd(qo);
				if(serviceResultDto.getSuccess()) {
					OperationLog operationLog=new OperationLog();
					operationLog.setOperationType(2);
					operationLog.setOperationDescription("课程添加!");
					operationLog.setUserId(user);
					operationLog.setOperationTime(new Date());
					operationLog.setOperationUserName(user.getUserName());
					operationLogService.save(operationLog);
					return "200";
				}
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return "500";
	}


	//课程回放修改course_update
	@ResponseBody
	@RequestMapping(value= "/coursesPlayback_update")
	public String update(HttpServletRequest request, HttpServletResponse response, Model model,String fileName,CoursesPlaybackQo q) {
		Map<String, Object> resMap=new HashMap<String, Object>();
		try {
			User user=(User)Jurisdiction.getSession().getAttribute(com.nhjf.common.Constants.USER_INFO);
			SysProperties sysProperties1=SysProperties.getInstance();
			String fileTemPath=sysProperties1.get("coursesPlaybackPath");
			String filePath=sysProperties1.get("fileUploadPath");
			SysProperties sysProperties=SysProperties.getInstance();
			String imgPath=sysProperties.get("imagePlaybackPath");
			if ( user== null) {
				// 跳转到登录页面
				response.sendRedirect(request.getContextPath()+"/login");
			}
			if(q.getCoursesPlaybackId()==null) {
				resMap.put("code", "404");
				resMap.put("message", "没有此账号！");
				return JSONObject.fromObject(resMap).toString();
			}
			CoursesPlaybackQo coursesQo=new CoursesPlaybackQo();
			coursesQo.setCoursesPlaybackId(q.getCoursesPlaybackId());
			CoursesPlayback courses=coursesPlaybackService.queryUnique(coursesQo);
			MultipartFile pic = null;
			boolean isMultipart = ServletFileUpload.isMultipartContent(request);
			if (isMultipart){ 
				MultipartHttpServletRequest multipartRequest = WebUtils.getNativeRequest(request, MultipartHttpServletRequest.class);
				pic = multipartRequest.getFile("pic");
				if(pic==null) {
					if(StringUtils.isNotBlank(fileName)) {
						PictureUtil.copyFile(fileTemPath+user.getId()+"/"+fileName, filePath+user.getId()+"/"+fileName);
						File source = new File(filePath+user.getId()+"/"+fileName);
						Encoder encoder = new Encoder();
						String length = "";
						MultimediaInfo m = encoder.getInfo(source);
						System.out.println("-------"+m.getDuration());
						long ls = m.getDuration()/1000;
						int hour = (int) (ls/3600);
						int minute = (int) (ls/60);
						int second = (int) (ls-hour*3600-minute*60);
						length = minute+":"+second;
						q.setViewTime(length);
						q.setVideo(user.getId()+"/"+fileName);
						String delfile=filePath+courses.getVideo();
						File delvidel = new File(delfile);
						// 路径为文件且不为空则进行删除  
						if (delvidel.isFile() && delvidel.exists()) {  
							delvidel.delete();  
						}
						PictureUtil.copyFile(fileTemPath+user.getId()+"/"+fileName, filePath+user.getId()+"/"+fileName);
					}
					ServiceResultDto ts= coursesPlaybackService.findpmodify(q);
					if(ts.getSuccess()) {
						OperationLog operationLog=new OperationLog();
						operationLog.setOperationType(3);
						operationLog.setOperationDescription("课程修改!");
						operationLog.setUserId(user);
						operationLog.setOperationTime(new Date());
						operationLog.setOperationUserName(user.getUserName());
						operationLogService.save(operationLog);
						return "200";
					}
				}else {


					String imge =imgPath+courses.getImge();
					File dest = new File(imge);
					// 路径为文件且不为空则进行删除  
					if (dest.isFile() && dest.exists()) {  
						dest.delete();  
					}
					if (pic.isEmpty()) {
						resMap.put("code", "500");
						resMap.put("message", "上传图片不可为空");
						return JSONObject.fromObject(resMap).toString();
					}
					int returnTag = -1;

					// 获取图片原始文件名
					String originalFilename = pic.getOriginalFilename();
					System.out.println(originalFilename);
					//文件名使用当前时间
					String name = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date());
					// 获取上传图片的扩展名(jpg/png/...)
					String extension = FilenameUtils.getExtension(originalFilename);
					String[] regular = { "JPG", "GIF","PNG","JPEG" ,"BMP"};
					boolean flag1 = false;
					// 判断文件格式是否合法
					for (String str : regular) {
						if (extension.equalsIgnoreCase(str)) {
							flag1 = true;
						}
					}
					if (!flag1) {
						returnTag = 0;
						resMap.put("code", "500");
						resMap.put("message", "上传图片格式不正确！");
						return JSONObject.fromObject(resMap).toString();
					}
					// 图片上传的相对路径（因为相对路径放到页面上就可以显示图片）
					String path =imgPath + name + "." + extension;
					//图片上传的绝对路径
					File dir = new File(path);
					if (!dir.exists()) {
						dir.mkdirs();
					}
					// 上传图片
					pic.transferTo(new File(path));
					if(StringUtils.isNotBlank(fileName)) {
						q.setVideo(user.getId()+"/"+fileName);
						String delfile=filePath+courses.getVideo();
						File delvidel = new File(delfile);
						// 路径为文件且不为空则进行删除  
						if (delvidel.isFile() && delvidel.exists()) {  
							delvidel.delete();  
						}
						PictureUtil.copyFile(fileTemPath+user.getId()+"/"+fileName, filePath+user.getId()+"/"+fileName);
						File source = new File(filePath+user.getId()+"/"+fileName);
						Encoder encoder = new Encoder();
						String length = "";
						MultimediaInfo m = encoder.getInfo(source);
						System.out.println("-------"+m.getDuration());
						long ls = m.getDuration()/1000;
						int hour = (int) (ls/3600);
						int minute = (int) (ls/60);
						int second = (int) (ls-hour*3600-minute*60);
						length = minute+":"+second;
						q.setViewTime(length);
						q.setImge(name + "." + extension);
						ServiceResultDto ts= coursesPlaybackService.findpmodify(q);
						if(ts.getSuccess()) {
							OperationLog operationLog=new OperationLog();
							operationLog.setOperationType(3);
							operationLog.setOperationDescription("课程修改!");
							operationLog.setUserId(user);
							operationLog.setOperationTime(new Date());
							operationLog.setOperationUserName(user.getUserName());
							operationLogService.save(operationLog);
							return "200";
						}
					}

				}
			}else {
				if(StringUtils.isNotBlank(fileName)) {
					q.setVideo(user.getId()+"/"+fileName);
					String delfile=filePath+courses.getVideo();
					File delvidel = new File(delfile);
					// 路径为文件且不为空则进行删除  
					if (delvidel.isFile() && delvidel.exists()) {  
						delvidel.delete();  
					}
					PictureUtil.copyFile(fileTemPath+user.getId()+"/"+fileName, filePath+user.getId()+"/"+fileName);
				}
				ServiceResultDto ts= coursesPlaybackService.findpmodify(q);
			}

		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			return "500";
		}
		return "500";
	}


	//课程删除
	@ResponseBody
	@RequestMapping("/coursesPlayback_delete")
	public String delete(HttpServletRequest request,HttpSession session,HttpServletResponse response,String id) {

		try {
			User user=(User)Jurisdiction.getSession().getAttribute(com.nhjf.common.Constants.USER_INFO);
			if ( user== null) {
				// 跳转到登录页面
				response.sendRedirect(request.getContextPath()+"/login");
			}
			if(id==null && id=="") {
				return "500";
			}else{
				CoursesPlaybackQo coursesQo=new CoursesPlaybackQo();
				coursesQo.setCoursesPlaybackId(Long.parseLong(id));
				coursesQo.setSeachTeacher(true);
				CoursesPlayback cs=coursesPlaybackService.queryUnique(coursesQo);
				TeachersQo teachersQo=new TeachersQo();

				teachersQo.setSeachOrganization(true);
				teachersQo.setSeachUser(true);
				teachersQo.setTeacherId(cs.getUploader().getId());
				Teacher teacher=teachersService.queryUnique(teachersQo);
				teacher.setCoursesNum(teacher.getCoursesNum()-1);
				teachersService.update(teacher);
				SysProperties sysProperties=SysProperties.getInstance();
				String imgPath=sysProperties.get("imagePlaybackPath");
				File dest = new File(imgPath+cs.getImge());
				// 路径为文件且不为空则进行删除  
				if (dest.isFile() && dest.exists()) {  
					dest.delete();  
				}
				String videoPath=sysProperties.get("videofile");
				File dest2 = new File(videoPath+cs.getVideo());
				if(dest2.isFile() && dest.exists()) {
					dest2.delete();
				}
				coursesPlaybackService.deleteById(Long.parseLong(id));
				OperationLog operationLog=new OperationLog();
				operationLog.setOperationType(1);
				operationLog.setOperationDescription("课程删除!");
				operationLog.setUserId(user);
				operationLog.setOperationTime(new Date());
				operationLog.setOperationUserName(user.getUserName());
				operationLogService.save(operationLog);
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return "500";
		}
		return "200";
	}
}


